*{ Use the forum as user }*

#{fixture delete:'all', load:'test-data.yml' /}

#{selenium  'Try to add a lot of messages'}
	clearSession()
	
	// Home page
	open('/')
	assertTextPresent('Still not a member ?')
	assertTextPresent('Forums')
	assertTextPresent('SysUsers help')
	assertTextPresent('About this sample application')
	assertTextPresent('7 posts in 4 topics')
	
	// Login
	clickAndWait('link=Login')
	assertTextPresent('Login')
	assertTextPresent('Email')
	assertTextPresent('Password')
	type('email', 'jojo@sampleforum.com')
	type('password', 'hello')
	clickAndWait('loginButton')
	assertTextPresent('Welcome back Jojo !')
	assertTextPresent('2 posts in 2 topics')
	assertTextNotPresent('Still not a member ?')
	
	// Go to forums
	clickAndWait('link=Forums')
	assertTextPresent('Forums')
	clickAndWait('link=About')
	assertTextPresent('Post a new topic')
	assertTextNotPresent('Administrator options')
		
	#{list items:1..5, as:'topicNumber'}
	
	    // Create a topic
	    clickAndWait('link=Post a new topic')
	    assertTextPresent('New topic')
	    type('subject', 'Topic n°${topicNumber}')
	    type('contentText', 'Hop')
	    clickAndWait('postTopic')
	    
	    #{list items:1..5, as:'replyNumber'} 
	    
	        clickAndWait('link=Reply')
	        type('contentText', 'Reply n°${replyNumber}')
	        clickAndWait('postReply')
	        
	    #{/list}
	    
	    clickAndWait('link=About')
	
	#{/list}
	
	// Hop
	assertTextPresent('31 posts in 6 topics')
	clickAndWait('link=Jojo')
	assertTextPresent('32 posts in 7 topics')
	
	// Login as admin
	clickAndWait('link=Logout')
	clickAndWait('link=Login')
	type('email', 'admin@sampleforum.com')
	type('password', 'hello')
	clickAndWait('loginButton')
	clickAndWait('link=Forums')
	clickAndWait('link=About')
	clickAndWait('deleteIt')
	assertTextPresent('6 posts in 3 topics')
	clickAndWait('link=Logout')
	
#{/selenium}